<template>
	<view class="content">
		<view v-if="!userinfo">
			<image class="img" src="../../static/my.png" mode=""></image>
		</view>
		<view v-else>
			<image class="img" src="../../static/head_icon.png" mode=""></image>
		</view>
		<view v-if="!userinfo">
			<button @click="toLogin" type="primary" style="width: 200rpx;">去登录</button>
		</view>
		<view v-else>
			<text>{{userinfo.name}}</text>
		</view>
		<view class="item">
			<view class="item-list">个人信息<image src="../../static/right.png"></image>
			</view>
			<view class="item-list">我的日程<image src="../../static/right.png"></image>
			</view>
			<view class="item-list">选课管理<image src="../../static/right.png"></image>
			</view>
			<view class="item-list">成绩查询<image src="../../static/right.png"></image>
			</view>
			<view class="item-list">校园服务<image src="../../static/right.png"></image>
			</view>
		</view>
		<button v-if="userinfo" class="button" type="primary" size="default" @click="logout">退出</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userinfo:false
			}
		},
		methods: {
			logout(){
				uni.clearStorage()
				this.userinfo=false
			},
			toLogin(){
				uni.navigateTo({
					url:'../login/login'
				})
			}
		},
		onShow() {
			uni.getStorage({
				key: 'userinfo',
				success: (res) => {
					console.log(res);
					this.userinfo=res.data
					// console.log(this.userinfo);
				}
			})
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 100%;
		height: 100%;

	}

	.img {
		width: 150rpx;
		height: 150rpx;
		border-radius: 50%;
		margin: 50rpx;
	}

	.item {
		width: 90%;
		/* background-color: #888; */
		margin-top: 100rpx;
	}

	.item .item-list {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		height: 80rpx;
		align-items: center;
		border-bottom: #333 solid 1rpx;
	}

	.item .item-list:first-child {
		border-top: #000000 solid 1rpx;
	}

	.item .item-list image {
		width: 48rpx;
		height: 48rpx;
	}

	.button {
		width: 90%;
		margin-top: 50rpx;
	}
</style>